package countdownlatch;

import java.util.concurrent.CountDownLatch;

/**
 * @ClassName CountDownLatchTest
 * @Description
 * @Author yuhang11
 * @Date 2022/1/4 2:49 下午
 * @Version 1.0
 */
public class CountDownLatchTest {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch count = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                try {
                    System.out.println(System.currentTimeMillis());
                }catch (Exception e){
                    e.printStackTrace();
                }finally {
                    count.countDown();
                }
            }).start();
        }
        System.out.println("等待子现成结束");
        count.await();
        System.out.println("子线程运行结束");
    }
}
